package com.aaa.three.controller;

import com.aaa.three.aop.Log;
import com.aaa.three.pojo.query.NewsQuery;
import com.aaa.three.pojo.vo.NewsVO;
import com.aaa.three.result.AjaxResult;
import com.aaa.three.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author: whf
 * @Date: 2022/2/15 11:07
 */
@RestController
@RequestMapping("news")
public class NewsController {

    @Autowired
    private NewsService newsService;

    @RequestMapping("list")
    public AjaxResult list(NewsQuery newsQuery) {
        return newsService.queryNews(newsQuery);
    }

    @RequestMapping("addNews")
    @Log("添加新闻")
    public AjaxResult addNews(NewsVO newsVO) {
        return newsService.addNews(newsVO);
    }

    @RequestMapping("updateNews")
    public AjaxResult updateNews (NewsVO newsVO) {
        return newsService.updateNews(newsVO);
    }

    @RequestMapping("deleteNews/{id}")
    @Log("删除新闻")
    public AjaxResult deleteNews(@PathVariable("id") Integer id) {
        return newsService.deleteNews(id);
    }

    @RequestMapping("getNews/{id}")
    public AjaxResult getNews(@PathVariable("id") Integer id) {
        return newsService.getNewsById(id);
    }

    @RequestMapping("updateQueryNews/{id}")
    @Log("修改新闻")
    public AjaxResult updateQueryNews(@PathVariable("id") Integer id) {
        return newsService.updateQueryNews(id);
    }

    @RequestMapping("updatePassCondition/{id}")
    @Log("审核通过")
    public AjaxResult updatePassCondition(@PathVariable("id") Integer id) {
        return newsService.updatePassCondition(id);
    }

    @RequestMapping("updateFailCondition")
    @Log("审核不通过")
    public AjaxResult updateFailCondition(NewsVO newsVO) {
        return newsService.updateFailCondition(newsVO);
    }

}
